From: Matthieu Gallien Date: Mon, 7 Apr 2025 13:37:41 +0000 (+0200) Subject: stop using QFile api to delete a single local file X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~42^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=147a033f883ba9cb34e8cdf47a4e3bde848042e7;p=nextcloud-desktop.git stop using QFile api to delete a single local file Signed-off-by: Matthieu Gallien --- diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index ffcd4f36b..b63f6c1a7 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -588,13 +589,30 @@ bool FileSystem::remove(const QString &fileName, QString *errorString) // allow that. setFileReadOnly(fileName, false); #endif - QFile f(fileName); - if (!f.remove()) { + + try { + if (!std::filesystem::remove(std::filesystem::path{fileName.toUtf8().data()})) { + if (errorString) { + *errorString = QObject::tr("File is already deleted"); + } + return false; + } + } + catch (const std::filesystem::filesystem_error &e) + { if (errorString) { - *errorString = f.errorString(); + *errorString = QString::fromLatin1(e.what()); } return false; } + catch (...) + { + if (errorString) { + *errorString = QObject::tr("Error deleting the file"); + } + return false; + } + return true; }